import {
  exportUrl,
  getBarcodePrintTempList,
  getYesOrNot
} from "@/api/print/mesCapacityCodeInfo"
import {
  templateType, //获取生码分类
} from "@/api/print/mesCapacityCode";
// 列表头按钮配置

export const operateList = [{
  name: $i18n.t("common.export"),
  type: "primary",
  icon: "el-icon-download",
  handleName: "export", //点击时返回的标识
  url: exportUrl
  //auth: "auth:operlog:export", //权限字段
}]

// 行末按钮配置
export const rowConfig = [{
  name: $i18n.t("common.view"),
  type: "primary",
  class: "row-btn-primary",
  handleName: "show" //点击时返回的标识
}]

// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    orderCode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.orderCode")
    },
    barcode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.uniqueCode")
    },

    prodCode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.modelCode")
    },
    prodName: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.modelName")
    },
    planBeginDate: {
      type: "daterange",
      label: $i18n.t("capacityCodeInfo.planBeginDate"),
      attrs: {
        valueFormat: "yyyy-MM-dd",
        searchArrKey: ["planBeginDateMin", "planBeginDateMax"]
      }
    },
    barcodePrintTemp: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.barcodePrintTemp"),
      prop: {
        value: "templateName",
        text: "templateName"
      },
      options: async (data) => {
        const list = await getBarcodePrintTempList({
          activeFlag: "Y"
        })
        return list.data.result
      }
    },
    isPrint: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.isPrint"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getYesOrNot()
        return list.data.result
      }
    },
    isSubmitted: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.isSubmitted"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getYesOrNot()
        return list.data.result
      }
    }
  }
}

// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: true,
  isShowSubmitBtn: false,
  formDesc: {
    planCode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.planCode"),
      layout: 12,
      required: false
    },
    barcode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.uniqueCode"),
      layout: 12,
      required: false
    },
    prodCode: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.modelCode"),
      layout: 12,
      required: false
    },
    prodName: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.modelName"),
      layout: 12,
      required: false
    },
    // prodName: {
    //   type: "input",
    //   label: $i18n.t("capacityCodeInfo.modelName"),
    //   layout: 12,
    //   required: false
    // },
    count: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.volume"),
      layout: 12,
      required: false
    },
    unit: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.unit"),
      layout: 12,
      required: false
    },
    capacityType: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.printSort"),
      layout: 12,
      prop: {
        value: "value",
        text: "description"
      },
      options: async data => {
        const params = {};
        const list = await templateType(params);
        return list.data.result;
      },
      disabled: false
    },
    seriesName: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.seriesName"),
      layout: 12,
      required: false
    },
    planBeginDate: {
      type: "date",
      label: $i18n.t("capacityCodeInfo.planBeginDate"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd"
      }
    },
    planEndDate: {
      type: "date",
      label: $i18n.t("capacityCodeInfo.planEndDate"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd"
      }
    },
    barcodePrintTemp: {
      type: "input",
      label: $i18n.t("capacityCodeInfo.barcodePrintTemp"),
      layout: 12,
      required: false
    },
    lineCode: {
      type: "input",
      label: $i18n.t("common.lineCode"),
      layout: 12,
      required: false
    },
    lineName: {
      type: "input",
      label: $i18n.t("common.lineName"),
      layout: 12,
      required: false
    },
    isPrint: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.isPrint"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getYesOrNot()
        return list.data.result
      }
    },
    isSubmitted: {
      type: "select",
      label: $i18n.t("capacityCodeInfo.isSubmitted"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getYesOrNot()
        return list.data.result
      }
    },
    remark: {
      type: "textarea",
      label: $i18n.t("common.remark"),
      layout: 12,
      required: false
    }
  }
}
